package cn.iocoder.yudao.module.agent.dal.mysql.brokeragewithdrawrecord;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.agent.dal.dataobject.brokeragewithdrawrecord.AgentBrokerageWithdrawRecordDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.agent.controller.admin.brokeragewithdrawrecord.vo.*;

/**
 * 代理人佣金提现记录 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface AgentBrokerageWithdrawRecordMapper extends BaseMapperX<AgentBrokerageWithdrawRecordDO> {

    default PageResult<AgentBrokerageWithdrawRecordDO> selectPage(AgentBrokerageWithdrawRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AgentBrokerageWithdrawRecordDO>()
                .eqIfPresent(AgentBrokerageWithdrawRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(AgentBrokerageWithdrawRecordDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(AgentBrokerageWithdrawRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AgentBrokerageWithdrawRecordDO::getId));
    }

    default List<AgentBrokerageWithdrawRecordDO> selectList(AgentBrokerageWithdrawRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AgentBrokerageWithdrawRecordDO>()
                .eqIfPresent(AgentBrokerageWithdrawRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(AgentBrokerageWithdrawRecordDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(AgentBrokerageWithdrawRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AgentBrokerageWithdrawRecordDO::getId));
    }

    default int updateByIdAndStatus(Long id, Integer status, AgentBrokerageWithdrawRecordDO updateObj) {
        return update(updateObj, new LambdaUpdateWrapper<AgentBrokerageWithdrawRecordDO>()
                .eq(AgentBrokerageWithdrawRecordDO::getId, id)
                .eq(AgentBrokerageWithdrawRecordDO::getStatus, status));
    }

}
